#include <srts/stratego.h>
#include <stratego-lib/stratego-lib.h>
void init_constructors (void)
{
}
static Symbol sym__3;
static Symbol sym__2;
static Symbol sym_Nil_0;
static Symbol sym_Id_1;
static Symbol sym_TypeId_1;
static void init_module_constructors (void)
{
sym__3 = ATmakeSymbol("", 3, ATfalse);
ATprotectSymbol(sym__3);
sym__2 = ATmakeSymbol("", 2, ATfalse);
ATprotectSymbol(sym__2);
sym_Nil_0 = ATmakeSymbol("Nil", 0, ATfalse);
ATprotectSymbol(sym_Nil_0);
sym_Id_1 = ATmakeSymbol("Id", 1, ATfalse);
ATprotectSymbol(sym_Id_1);
sym_TypeId_1 = ATmakeSymbol("TypeId", 1, ATfalse);
ATprotectSymbol(sym_TypeId_1);
}
static ATerm term3;
static ATerm term2;
static ATerm term1;
static ATerm term0;
static void init_module_constant_terms (void)
{
ATprotect(&(term0));
term0 = (ATerm) ATmakeAppl(ATmakeSymbol("bindings", 0, ATtrue));
ATprotect(&(term1));
term1 = term0;
ATprotect(&(term2));
term2 = (ATerm) ATmakeInt(2);
ATprotect(&(term3));
term3 = term2;
}
#include <srts/init-stratego-application.h>
extern const char * __tracing_table [];
extern unsigned short __tracing_table_counter;
ATerm table_get_0_0 (StrSL sl, ATerm t);
ATerm table_put_0_0 (StrSL sl, ATerm t);
ATerm table_destroy_0_0 (StrSL sl, ATerm t);
ATerm table_create_0_0 (StrSL sl, ATerm t);
ATerm take_1_0 (StrSL sl, StrCL m_83, ATerm t);
ATerm map_1_0 (StrSL sl, StrCL p_80, ATerm t);
ATerm zip_0_0 (StrSL sl, ATerm t);
ATerm Snd_0_0 (StrSL sl, ATerm t);
ATerm Fst_0_0 (StrSL sl, ATerm t);
ATerm try_1_0 (StrSL sl, StrCL v_57, ATerm t);
ATerm alltd_1_0 (StrSL sl, StrCL h_51, ATerm t);
ATerm env_alltd_1_0 (StrSL sl, StrCL g_48, ATerm t);
ATerm explode_string_0_0 (StrSL sl, ATerm t);
ATerm implode_string_0_0 (StrSL sl, ATerm t);
ATerm io_wrap_1_0 (StrSL sl, StrCL p_41, ATerm t);
static ATerm lifted5 (StrSL sl, ATerm t);
static ATerm lifted4 (StrSL sl, ATerm t);
ATerm match_p__0_0 (StrSL sl, ATerm t);
static ATerm lifted3 (StrSL sl, ATerm t);
ATerm match_0_0 (StrSL sl, ATerm t);
ATerm register_0_0 (StrSL sl, ATerm t);
ATerm clear_0_0 (StrSL sl, ATerm t);
static ATerm lifted0 (StrSL sl, ATerm t);
ATerm main_0_0 (StrSL sl, ATerm t);
ATerm match_p__0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "match_p__0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm c_17 = NULL,d_17 = NULL,e_17 = NULL,f_17 = NULL;
ATerm trm1 = t;
if(match_cons(t, sym__2))
{
d_17 = ATgetArgument(t, 0);
if(!((d_17 == ATgetArgument(t, 1))))
goto label1 ;
}
else
goto label1 ;
goto label0 ;
label1 :
t = trm1;
{
ATerm trm2 = t;
if(match_cons(t, sym__2))
{
ATerm trm3 = ATgetArgument(t, 0);
if(match_cons(trm3, sym_Id_1))
{
c_17 = ATgetArgument(trm3, 0);
}
else
goto label2 ;
d_17 = ATgetArgument(t, 1);
}
else
goto label2 ;
t = c_17;
t = explode_string_0_0(sl, t);
if((t == NULL))
goto label2 ;
{
struct str_closure p_164 = { &(lifted4) , &(frame) };
StrCL lifted4_cl = &(p_164);
t = take_1_0(sl, lifted4_cl, t);
if((t == NULL))
goto label2 ;
t = implode_string_0_0(sl, t);
if((t == NULL))
goto label2 ;
if(!((ATgetSymbol(t) == ATmakeSymbol("PH", 0, ATtrue))))
goto label2 ;
t = (ATerm) ATmakeAppl(sym__2, c_17, d_17);
t = register_0_0(sl, t);
if((t == NULL))
goto label2 ;
}
goto label0 ;
label2 :
t = trm2;
{
ATerm trm4 = t;
if(match_cons(t, sym__2))
{
ATerm trm5 = ATgetArgument(t, 0);
if(match_cons(trm5, sym_TypeId_1))
{
c_17 = ATgetArgument(trm5, 0);
}
else
goto label3 ;
d_17 = ATgetArgument(t, 1);
}
else
goto label3 ;
t = c_17;
t = explode_string_0_0(sl, t);
if((t == NULL))
goto label3 ;
{
struct str_closure q_164 = { &(lifted5) , &(frame) };
StrCL lifted5_cl = &(q_164);
t = take_1_0(sl, lifted5_cl, t);
if((t == NULL))
goto label3 ;
t = implode_string_0_0(sl, t);
if((t == NULL))
goto label3 ;
if(!((ATgetSymbol(t) == ATmakeSymbol("PH", 0, ATtrue))))
goto label3 ;
t = (ATerm) ATmakeAppl(sym__2, c_17, d_17);
t = register_0_0(sl, t);
if((t == NULL))
goto label3 ;
}
goto label0 ;
label3 :
t = trm4;
{
struct str_closure r_164 = { &(match_p__0_0) , sl };
StrCL lifted6_cl = &(r_164);
if(match_cons(t, sym__2))
{
ATerm trm6 = ATgetArgument(t, 0);
ATerm trm7,trm8;
trm7 = SSL_get_constructor(trm6);
trm8 = SSL_get_arguments(trm6);
d_17 = trm7;
e_17 = trm8;
{
ATerm trm9 = ATgetArgument(t, 1);
ATerm trm10,trm11;
trm10 = SSL_get_constructor(trm9);
trm11 = SSL_get_arguments(trm9);
if(!((d_17 == trm10)))
goto fail6 ;
f_17 = trm11;
}
}
else
goto fail6 ;
t = (ATerm) ATmakeAppl(sym__2, e_17, f_17);
t = zip_0_0(sl, t);
if((t == NULL))
goto fail6 ;
t = map_1_0(sl, lifted6_cl, t);
if((t == NULL))
goto fail6 ;
else
goto label0 ;
}
}
}
label0 :
;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail6 :
--__tracing_table_counter;
return(NULL);
}
static ATerm lifted5 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "lifted5";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
t = term3;
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail8 :
--__tracing_table_counter;
return(NULL);
}
static ATerm lifted4 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "lifted4";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
t = term3;
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail7 :
--__tracing_table_counter;
return(NULL);
}
ATerm match_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "match_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm z_16 = NULL,a_17 = NULL,b_17 = NULL;
struct str_closure o_164 = { &(lifted3) , &(frame) };
StrCL lifted3_cl = &(o_164);
if(match_cons(t, sym__2))
{
a_17 = ATgetArgument(t, 0);
{
ATerm trm0 = ATgetArgument(t, 1);
if(match_cons(trm0, sym__2))
{
z_16 = ATgetArgument(trm0, 0);
b_17 = ATgetArgument(trm0, 1);
}
else
goto fail4 ;
}
}
else
goto fail4 ;
t = clear_0_0(sl, t);
if((t == NULL))
goto fail4 ;
t = (ATerm) ATmakeAppl(sym__2, z_16, a_17);
t = match_p__0_0(sl, t);
if((t == NULL))
goto fail4 ;
t = b_17;
t = alltd_1_0(sl, lifted3_cl, t);
if((t == NULL))
goto fail4 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail4 :
--__tracing_table_counter;
return(NULL);
}
static ATerm lifted3 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "lifted3";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm d_164 = NULL,e_164 = NULL,f_164 = NULL,g_164 = NULL,h_164 = NULL;
if(match_cons(t, sym_Id_1))
{
d_164 = ATgetArgument(t, 0);
}
else
goto fail5 ;
f_164 = t;
t = d_164;
h_164 = t;
g_164 = t;
t = (ATerm) ATmakeAppl(sym__2, term1, g_164);
t = table_get_0_0(sl_up(sl), t);
if((t == NULL))
goto fail5 ;
e_164 = t;
t = f_164;
t = e_164;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail5 :
--__tracing_table_counter;
return(NULL);
}
ATerm register_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "register_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm t_16 = NULL,v_16 = NULL,u_16 = NULL,w_16 = NULL;
v_16 = t;
t = Fst_0_0(sl, t);
if((t == NULL))
goto fail3 ;
t_16 = t;
t = v_16;
w_16 = t;
t = Snd_0_0(sl, t);
if((t == NULL))
goto fail3 ;
u_16 = t;
t = w_16;
t = (ATerm) ATmakeAppl(sym__3, term1, t_16, u_16);
t = table_put_0_0(sl, t);
if((t == NULL))
goto fail3 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail3 :
--__tracing_table_counter;
return(NULL);
}
ATerm clear_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "clear_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
t = term1;
{
struct str_closure n_164 = { &(table_destroy_0_0) , sl };
StrCL lifted2_cl = &(n_164);
t = try_1_0(sl, lifted2_cl, t);
if((t == NULL))
goto fail2 ;
t = term1;
t = table_create_0_0(sl, t);
if((t == NULL))
goto fail2 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail2 :
--__tracing_table_counter;
return(NULL);
}
ATerm main_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "main_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
struct str_closure m_164 = { &(lifted0) , &(frame) };
StrCL lifted0_cl = &(m_164);
t = io_wrap_1_0(sl, lifted0_cl, t);
if((t == NULL))
goto fail0 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail0 :
--__tracing_table_counter;
return(NULL);
}
static ATerm lifted0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "lifted0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm a_164 = NULL,b_164 = NULL,c_164 = NULL;
struct str_closure l_164 = { &(match_0_0) , sl_up(sl) };
StrCL lifted1_cl = &(l_164);
if(match_cons(t, sym__3))
{
b_164 = ATgetArgument(t, 0);
c_164 = ATgetArgument(t, 1);
a_164 = ATgetArgument(t, 2);
}
else
goto fail1 ;
t = (ATerm) ATmakeAppl(sym__2, a_164, (ATerm) ATmakeAppl(sym__2, b_164, c_164));
t = env_alltd_1_0(sl_up(sl), lifted1_cl, t);
if((t == NULL))
goto fail1 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail1 :
--__tracing_table_counter;
return(NULL);
}
static void register_strategies (void)
{
int initial_size = 117;
int max_load = 75;
struct str_closure * closures;
int closures_index = 0;
if((strategy_table == NULL))
strategy_table = ATtableCreate(initial_size, max_load);
closures = (struct str_closure*) malloc((sizeof(struct str_closure) * 24));
if((closures == NULL))
{
perror("malloc error for registration of dynamic strategies");
exit(1);
}
closures[closures_index].fun = &(table_get_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("table_get_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(table_put_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("table_put_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(table_destroy_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("table_destroy_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(table_create_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("table_create_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(take_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("take_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(map_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("map_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(zip_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("zip_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(Snd_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("Snd_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(Fst_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("Fst_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(try_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("try_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(alltd_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("alltd_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(env_alltd_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("env_alltd_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(explode_string_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("explode_string_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(implode_string_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("implode_string_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(io_wrap_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("io_wrap_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(lifted5);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("lifted5", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(lifted4);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("lifted4", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(match_p__0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("match_p__0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(lifted3);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("lifted3", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(match_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("match_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(register_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("register_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(clear_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("clear_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(lifted0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("lifted0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(main_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("main_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
}
int main (int argc, char * argv [])
{
ATerm out_term;
ATermList in_term;
int i;
ATinit(argc, argv, &(out_term));
init_constructors();
in_term = ATempty;
for ( i = (argc - 1) ; (i >= 0) ; i-- )
{
in_term = ATinsert(in_term, (ATerm) ATmakeAppl0(ATmakeSymbol(argv[i], 0, ATtrue)));
}
SRTS_stratego_initialize();
memset(__tracing_table, 0, (sizeof(unsigned short) * TRACING_TABLE_SIZE));
__tracing_table_counter = 0;
register_strategies();
out_term = main_0_0(NULL, (ATerm) in_term);
if((out_term != NULL))
{
ATfprintf(stdout, "%t\n", out_term);
exit(0);
}
else
{
ATfprintf(stderr, "%s: rewriting failed, trace:\n", argv[0]);
for ( i = 0 ; (__tracing_table[i] && (i < TRACING_TABLE_SIZE)) ; i++ )
ATfprintf(stderr, "\t%s\n", __tracing_table[i]);
exit(1);
}
}
